package com.itheima.edu.info.manager.C_Service;


import com.itheima.edu.info.manager.D_Dao.LaoShiDao;
import com.itheima.edu.info.manager.E_domain.LaoShi;


import java.util.ArrayList;

public class LaoShiService {
    ArrayList<LaoShi> list;
    LaoShiDao laoShi = new LaoShiDao();
    //判断ID是否相同，相同为true，不同false
    int index;
    public boolean panDuanID(String id) {
        boolean bl = false;
        list = laoShi.geArrayList();
        for (int i = 0; i < list.size(); i++) {
            LaoShi L = list.get(i);
            if (L.getID().equals(id)) {
                index = i;
                return bl = true;
            }
        }
        return bl;
    }

    public void tianjia(LaoShi ls) {
        laoShi.tianjia(ls);
    }

    public ArrayList<LaoShi> chaKan() {

        return laoShi.geArrayList();
    }

    public void xiuGai(LaoShi ls) {
        list.set(index, ls);
        System.out.println("修改成功");


    }


    public void shanChu(String s) {
        panDuanID(s);
        laoShi.shanChu(index);

    }
}
